

#include "Test.h"

#if TEST_UART
#include "Led.h"
#include "BSP_Delay.h"
#include "BSP_Uart.h"
#include "Debug.h"

uint8_t rxFlag;
uint8_t rxData;

static void testUartRxCallback(uint8_t rx){
	rxFlag = 1;
	rxData = rx;
}

static void testUartSend(void){
	uint8_t tx = 0;
	uint8_t i;
	
	for(i = 0; i < 10; ++i){
		BSP_Uart_Send('A' + tx);
		tx++;
		BSP_Delay_ms(10);
	}
}

static void testUartEcho(void){
	BSP_Uart_SetRxCallback(testUartRxCallback);
	while(1){
		if(rxFlag){
			rxFlag = 0;
			BSP_Uart_Send(rxData);
		}	
	}
}

void TestUart(void){
DBG_WRITE("TestUart:\r\n");

	BSP_Uart_Init();
	testUartSend();
	testUartEcho();
}

#endif 


